$('.menu > li').live(
	'click',
	function(){
		
	}
);

$('.opt-btn-group').live(
	'mouseover',
	function(){
		$(this).animate({'opacity':1});
	}
).live(
	'mouseout',
	function(){
		$(this).animate({'opacity':0.6});
	}
);


//删除
$(".news-del").live(
		'click',
		function(){
			window.location.hash = '';
			window.location.hash = 'edit';
			 $(this).closest(".photo-box").remove();
			var id = $(this).attr('groupid');
			
			$.get(
				'/photoGroup/delete',
				{
					'id': id
				},
				function(data){
				 alert("操作成功！");		
				}
			);
			
		}	
);



//group 编辑
$("#groupEdit").live(
		'click',
		function(){
			window.location.hash = '';
			window.location.hash = 'edit';
			
			var id = $(this).attr('groupid');
			
			$.get(
				'/photoGroup/find',
				{
					'id': id
				},
				function(data){
					$('#edit-title').val(data.data.name);
					$('#edit-pic').val(data.data.url);
					$('#edit-id').val(data.data.id);		
				}
			);
			
		}	
);

$("#saveGroup").live(
		  'click',
		  function(){
		     			 var newsId = $("#edit-id").val();
						 var picurl = $("#edit-pic").val();
						 var name   = $("#edit-title").val();
						
						 
			param = {
			  "id":newsId,
			  "name":name,
			  "url":picurl
			};
		  $.ajax({
					url:"/photoGroup/update.action" ,
					type:"POST",
					data:param,
					dataType:"json",
					success: function(data){
					alert("操作成功！");}
					});
		  
 });
		    
// 创建相册
$("#addGroup").live(
		  'click',
		  function(){
						 var picurl = $("#edit-pic").val();
						 var name   = $("#edit-title").val();
						 var userId = $("#userId").val();
			param = {
			  "name":name,
			  "url":picurl,
			  "userId":userId
			};
		  $.ajax({
					url:"/photoGroup/add.action" ,
					type:"POST",
					data:param,
					dataType:"json",
					success: function(data){
					alert("操作成功！");}
					});
		  
});
		
		
//创建相片
$("#addphoto").live(
		  'click',
		  function(){
						 var picurl = $("#photo-pic").val();
						 var name   = $("#photo-title").val();
						 var groupId = $("#groupId").val();
			param = {
			  "name":name,
			  "url":picurl,
			  "groupId":groupId
			};
		  $.ajax({
					url:"/photo/add.action" ,
					type:"POST",
					data:param,
					dataType:"json",
					success: function(data){
					alert("操作成功！");}
					});
		  
});

//删除相片
$("#deletePhoto").live(
		  'click',
		  function(){
						 var id = $("#photoId").text();
						 var groupId = $("#groupId").val();
			param = {
			  "id":id,
			  "groupId":groupId
			};
			location.href="/photo/delete.action?id="+id+"&&groupId="+groupId;
		       /**
			   $.ajax({
					url:"/photo/delete.action" ,
					type:"POST",
					data:param,
					dataType:"json",
					success: function(data){
					}
					});
					*/
		  
});

$('.thumbnail').live(
	'mouseenter',
	function(){
		$(this).addClass('thumbnail-boder');
	}
	).live(
	'mouseleave',
	function(){
		$(this).removeClass('thumbnail-boder');
	}
);	


$('.thumbnail > a').live(
	'click',
	function(){
		var imgUrl = $(this).children('img').attr('src');
		TINY.box.show({image:imgUrl,boxid:'frameless',animate:true,openjs:function(){openJS();}});
	}
);